#ifndef CHARACTERCLASS_H
#define CHARACTERCLASS_H


#include "dtwenty_global.h"


#include "classspecialabilities.h"


#include <data.h>


#include <QMetaType>


class DTWENTYSHARED_EXPORT ClassSkills : public Collection
{
    Q_OBJECT

public:

    enum Field
    {
        Field_FIRST = 0,

        Field_SKILL = Field_FIRST,

        Field_LAST = Field_SKILL
    };


    Q_INVOKABLE ClassSkills(QObject *parent = 0) :
        Collection(QT_TR_NOOP("Class Skills"), parent)
    {
    }

    ClassSkills(const ClassSkills& other) :
        Collection(other)
    {
    }

    Q_INVOKABLE virtual void onInitialize()
    {
        setField(Field_SKILL, QT_TR_NOOP("Skill"));

        MetaItem* metaItem = metaData()->item(Field_SKILL);
        metaItem->setOptionRef("Skills");
    }

};


Q_DECLARE_METATYPE(ClassSkills*)



class DTWENTYSHARED_EXPORT CharacterClass : public Collection
{
    Q_OBJECT

public:

    enum Field
    {
        Field_FIRST = 0,

        Field_HITDIE = Field_FIRST,
        Field_SKILLPOINTS,

        Field_LAST = Field_SKILLPOINTS

    };

    Q_INVOKABLE CharacterClass(QObject *parent = 0) :
        Collection(QT_TR_NOOP("New Character Class"), parent)
    {
    }

    CharacterClass(const CharacterClass& other) :
        Collection(other)
    {
    }

    Q_INVOKABLE virtual void onInitialize()
    {
        setField(Field_HITDIE, QT_TR_NOOP("HitDie"));
        setField(Field_SKILLPOINTS, QT_TR_NOOP("SkillPoints"));

        MetaItem* metaItem = metaData()->item(Field_HITDIE);
        metaItem->setOptionRef("Dice");

        // todo: meta item could have static options in par of dynamic options.
        metaItem = metaData()->item(Field_SKILLPOINTS);

        if (!findChild<Item*>("Class Features"))
        {
            Item* item = qobject_cast<Item*>(create("Item", this));
            item->setObjectName("Class Features");
        }

        if (!findChild<ClassSkills*>()) Collection::create("ClassSkills", this);
        if (!findChild<ClassSpecials*>()) Collection::create("ClassSpecials", this);
    }

};


Q_DECLARE_METATYPE(CharacterClass*)



#endif // CHARACTERCLASS_H
